package com.lunan.mytools;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


public class MyApplication extends Application {
    private static MyApplication mApp;
    private static DaoSession mDaoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        mApp = this;
        //配置数据库
        initGreenDao();
    }

    private void initGreenDao() {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(mApp,"mydb.db");
        SQLiteDatabase database =  helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(database);

        mDaoSession = daoMaster.newSession();
    }

    public static Context getContext(){
        return mApp.getBaseContext();
    }

    public static DaoSession getmDaoSession(){
        return mDaoSession;
    }
}
